import flash.events.Event;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Matrix;
import flash.text.TextField;
import flash.text.TextFormat;

import Images;
class PauseMenuEvent extends Event{
 
	public function new(customEventString:String){

	super(customEventString, true, false);

    }
}

class PauseMenu extends Sprite
{
private var VolumeButton:Sprite;
private var SoundEffectsButton:Sprite;
private var Text:TextField;

// public var volume:Bool;
// public var sound:Bool;

  public function new()
  {
  super();
  //Resize Image
  var background = new Sprite();
      background.graphics.lineStyle(1);
    background.graphics.beginFill(0xFFFFFF);
    background.graphics.drawCircle(150, 150,150);
    background.graphics.endFill();
background.x = 180; background.y = 30;
  //End Resize
  addChild(background);

 Text = new TextField();
    
  Text.x = 275; Text.y = 40;
  Text.width = 540; Text.height = 420;
  addChild(Text);
  Text.multiline = true;
  Text.selectable = false;
  var myFormat:TextFormat = new TextFormat();
  myFormat.size = 22;
  //myFormat.align = TextFormatAlign.CENTER;
  Text.defaultTextFormat = myFormat;
  
  Text.htmlText = "Pause Menu";

  VolumeButton  = new Sprite();
  VolumeButton.graphics.beginBitmapFill(new Volume());
  VolumeButton.graphics.drawRect(0, 0, 113 ,113);
  VolumeButton.x = 195;
  VolumeButton.y = 150;
  VolumeButton.buttonMode = true;
  VolumeButton.addEventListener(MouseEvent.CLICK, onVolumeButtonClick);
  addChild(VolumeButton);

  var QuitButton  = new Sprite();
  QuitButton.graphics.lineStyle(1);
  QuitButton.graphics.beginFill(0x0000000);
  QuitButton.graphics.drawCircle(45, 45,48);
  QuitButton.graphics.endFill();
  QuitButton.x = 370;
  QuitButton.y = 158;
  QuitButton.buttonMode = true;
  var QuitText = new TextField();
  QuitText.htmlText = "<font color='#FFFFFF' size='32'>Quit</font>";
  QuitText.x = 13;QuitText.y = 20;
  QuitText.selectable =  false;
  QuitButton.addChild(QuitText);
  QuitButton.addEventListener(MouseEvent.CLICK, onQuitButtonClick);
  addChild(QuitButton);

  }

public function renderVolume(volume:Bool)
{
  if(volume)
  {
  VolumeButton.graphics.clear();
  VolumeButton.graphics.beginBitmapFill(new Volume());
  VolumeButton.graphics.drawRect(0, 0, 113 ,113);
  }
  else
  {
  VolumeButton.graphics.clear();
  VolumeButton.graphics.beginBitmapFill(new VolumeMuted());
  VolumeButton.graphics.drawRect(0, 0, 113 ,113);
  }

}

private function onQuitButtonClick(event:MouseEvent)  {
  dispatchEvent(new PauseMenuEvent("Quit"));
}

private function onVolumeButtonClick(event:MouseEvent)  {
  dispatchEvent(new PauseMenuEvent("VolumeToggle"));
}

}